Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
Why are certain values written via [ngModel] not updating in the UI?

I am seeing inconsistent behavior where the UI does not update correctly for certain values written to a field bound to [ngModel].

My template:

<input
  type="number"
  [ngModel]="displayValue"
  (ngModelChange)="updateValue($event)"
/>

TS file:

export class HelloComponent {
  displayValue = 0;

  public updateValue(displayValue: number) {
    const validatedValue = this.constrainValue(displayValue);
    this.displayValue = validatedValue;
  }

  private constrainValue(value: number) {
    return (value > 100) ? 100 : value;
  }
}
  • If I enter a 3 digit number over 100 (ie: 230), constrainValue adjusts it to 100 and they UI updates as expected.
  • If I enter a 6 digit number (ie: 23456), constrainValue adjusts it to 100 but the UI only updates the first 3 numbers so I get 10056.

Stackblitz: https://stackblitz.com/edit/angular-ivy-eleb1u?file=src%2Fapp%2Fhello.component.ts

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda